package com.xybean.dao;

import java.io.Serializable;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.SQLQuery;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Criterion;

import com.xybean.dao.page.PageResult;

public interface DAO<E> {
	public E save(E e);

	public E delete(E e);

	public E deletebyId(Integer id);

	public void update(E e);

	public E get(Serializable id);

	public <T> T findUniqByCriteria(Class<T> entityClass, Criterion... criterion);

	public E findUniqByCriteria(Criterion... criterion);

	public E findUniqByHql(String hql, Object... values);

	public List<E> getAll();

	public List<E> getList(String hql, Object... values);

	public List<E> getList(String hql, int limit, Object... values);

	public List getComplexList(String hql, int limit, Object... values);

	public List<E> getList(int limit, Criterion... criterions);

	public List<E> getList(Criterion... criterions);

	public List<E> getList(String ordertype, String property, Criterion... criterions);

	public List<E> getList(int limit, String ordertype, String property, Criterion... criterions);

	public List<E> getList(int limit, String[] ordertype, String[] property, Criterion... criterions);

	public Integer getTotalRecords(String hql, Object... values);

	public Integer getTotalRecords(Class<E> entityClass, Criterion... criterion);

	public Integer getTotalRecords(Criterion... criterion);

	public Criteria createCriteria(Class<?> entityClass, Criterion... criterion);

	public Criteria createCriteria(Criterion... criterion);

	public Criteria createCriteria();

	public PageResult<E> getPageResult(String hql, int currentPage, int pageSize, Object... values);

	public PageResult<E> getPageResult(Class<E> entityClass, int currentPage, int pageSize,
			Criterion... criterion);

	public PageResult<E> getPageResult(int currentPage, int pageSize, Criterion... criterion);

	public PageResult<E> getPageResultByLike(String name, String value, int currentPage, int pageSize);

	public PageResult<E> getPageResultByLike(String[] names, String[] values, int currentPage, int pageSize);

	public Query createQuery(String hql, Object... values);
	
	public SQLQuery createSQLQuery(String queryString, Object... values);
	
	public SessionFactory getSessionFactory();
	
	public void flush();
}
